<template>
  <div>
    <el-button @click="locale='zh'">中文</el-button>
    <el-button @click="locale='en'">English</el-button>
    <p>{{ t('sayhi') }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      locale: 'zh',
      message: {
        zh: {
          sayhi: '朋友，你好啊'
        },
        en: {
          sayhi: 'hello,myfriend'
        }
      }
    }
  },
  methods: {
    t(str) {
      const dict = this.message[this.locale]
      return dict[str]
    }
  }
}
</script>

<style>

</style>
